package com.fyy.sentinel.controller;

import com.alibaba.csp.sentinel.SphO;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Author fyy
 * @Description
 * @Date 2021/7/13 9:33
 */
@RestController
public class TestBooleanController {

    @RequestMapping(value = "/testBoo")
    public String test() {
        //SphO.entry 启用限流
        if (SphO.entry("TestBoo")) { //不存在限流
            try {
                return "你好，Sentinel";
            } finally { //保证SphO.entry需要和SphO.exit成对出现
                //SphO.entry需要和SphO.exit成对出现,
                //否则会影响到调用链记录,抛出异常
                SphO.exit();
            }
        } else { //存在限流
            return "系统繁忙！";
        }

    }

}
